home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / fviewsrc.zip / ARCHDR.H < prev    next >
Text File  |  1993-01-04  |  15KB  |  321 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /* Copyright 1989, Doug Boone.  FidoNet 119/5                               */
  4. /*                              (916) 893-9019 Data                         */
  5. /*                              (916) 891-0748 voice                        */
  6. /*                              P.O. Box 5108, Chico, CA. 95928             */
  7. /*                                                                          */
  8. /* This program is not for sale. It is for the free use with Opus systems.  */
  9. /* You may not sell it in ANY way. If you have an access charge to your     */
  10. /* Bulletin Board, consider this to be like Opus, you can ONLY make it      */
  11. /* available for download in an open area, where non-members can get access */
  12. /*                                                                          */
  13. /* If you need to modify this source code, please send me a copy of the     */
  14. /* changes you've made so that everyone can share in the updates.           */
  15. /*                                                                          */
  16. /* "Don't rip me off!" -- Tom Jennings, FidoNet's founder                   */
  17. /*                                                                          */
  18. /*--------------------------------------------------------------------------*/
  19.  
  20.  
  21. #ifndef fallthrough        /* "fallthrough" is in opus.h */
  22. typedef unsigned    char    byte;
  23. typedef unsigned    int     word;
  24. #endif
  25.  
  26.  
  27. /****** General purpose Symbolic constants:  *********/
  28. #define TRUE    1        /* general purpose true truth value */
  29. #define FALSE    0        /* general purpose false truth value */
  30. #define ERROR    -1        /* General "on error" return value */
  31. #define OK    0        /* General "no error" return value */
  32. #define EOS    '\0'        /* standard end of string */
  33.  
  34. #define MAX_PATH    78        /* max. length of full pathname        */
  35. #define MAX_DIR     66        /* max. length of full directory name    */
  36.  
  37. #define FOSSIL      0x0001        /* running remotely */
  38. #define MORE        0x0002        /* User wants More? prompts */
  39. #define WANTS_MORE  0x0004        /* User has more in User.BBS */
  40. #define VIEW        0x0008        /* View text files inside archive */
  41. #define    WATCH        0x0010        /* Use FOSSIL watchdog */
  42. #define OPUS_10     0x0020        /* Opus 1.03b */
  43. #define NO_SHOW        0x0040        /* Don't allow users to view files */
  44. #define DEBUG       0x0080
  45. #define ARC         0x1000        /* ARC/PAK file */
  46. #define ZIP         0x2000        /* PKZIP file */
  47. #define ZOO         0x4000        /* ZOO File */
  48. #define DWC         0x8000        /* DWC File */
  49. #define LZH         0x0100        /* Lharc File */
  50.  
  51. /*----------------------------------------------------------------------*/
  52. /*         Information for file date conversion            */
  53. /*----------------------------------------------------------------------*/
  54. #define MONTH_SHIFT     5
  55. #define MONTH_MASK      0x0F
  56. #define DAY_MASK    0x1F
  57. #define YEAR_SHIFT      9
  58. #define DOS_EPOCH       80
  59. #define HOUR_SHIFT      11
  60. #define HOUR_MASK       0x1F
  61. #define MINUTE_SHIFT    5
  62. #define MINUTE_MASK     0x3F
  63.  
  64. /*----------------------------------------------------------------------*/
  65. /*              archive list junk                */
  66. /*----------------------------------------------------------------------*/
  67. #define ARCMARK 26    /* special archive marker */
  68. #define ARCVER 10    /* highest compression code used */
  69.  
  70. #pragma pack(1)        /* req'd by MSC to keep struct byte aligned */ 
  71. struct heads        /* archive entry header format */
  72. {   
  73.     char mbrname[13];    /* file name */
  74.     long mbrsize;    /* size of file in archive, bytes */
  75.     unsigned mbrdate;    /* creation date */
  76.     unsigned mbrtime;    /* creation time */
  77.     int mbrcrc;        /* cyclic redundancy check */
  78.     long mbrlen;    /* true file size, bytes */
  79. };
  80. #pragma pack()        /* we now return to our regular programming */
  81.  
  82.  
  83. /*--------------------------------------------------------------------------*/
  84. /* Garbage for ZOO listing                                                  */
  85. /*--------------------------------------------------------------------------*/
  86.  
  87. #define MAJOR_VER 1        /* needed to manipulate archive */
  88. #define MINOR_VER 4
  89.  
  90. #define MAJOR_EXT_VER 1    /* needed to extract file */
  91. #define MINOR_EXT_VER 0
  92.  
  93. #define CTRL_Z 26
  94. #define ZOO_TAG ((unsigned long) 0xFDC4A7DC) /* A random choice */
  95. #define TEXT "ZOO 1.50 Archive.\032"   /* Header text for archive. */
  96. #define SIZ_TEXT  20                   /* Size of header text */
  97.  
  98. #define PATHSIZE 256                   /* Max length of pathname */
  99. #define FNAMESIZE 13                   /* Size of DOS filename */
  100. #define LFNAMESIZE 256                 /* Size of long filename */
  101. #define ROOTSIZE 8                     /* Size of fname without extension */
  102. #define EXTLEN 3                       /* Size of extension */
  103. #define FILE_LEADER  "@)#("            /* Allowing location of file data */
  104. #define SIZ_FLDR  5                    /* 4 chars plus null */
  105. #define MAX_PACK 1                     /* max packing method we can handle */
  106. #define BACKUP_EXT ".bak"              /* extension of backup file */
  107.  
  108. #ifdef OOZ
  109. #define FIRST_ARG 2
  110. #endif
  111.  
  112. #ifdef ZOO
  113. #define FIRST_ARG 3        /* argument position of filename list */
  114. #endif
  115.  
  116. /* WARNING:  Static initialization in zooadd.c or zooext.c depends on the 
  117.    order of fields in struct zoo_header */
  118. struct zoo_header {
  119.    char text[SIZ_TEXT];       /* archive header text */
  120.    unsigned long zoo_tag;     /* identifies archives           */
  121.    long zoo_start;            /* where the archive's data starts        */
  122.    long zoo_minus;      /* for consistency checking of zoo_start  */
  123.    char major_ver;
  124.    char minor_ver;            /* minimum version to extract all files   */
  125. };
  126.  
  127. /* Note:  Microsoft C aligns data at word boundaries.  So, to keep things
  128.    compact, always try to pair up character fields. */
  129. struct direntry {
  130.    unsigned long zoo_tag;     /* tag -- redundancy check */
  131.    char type;                 /* type of directory entry.  always 1 for now */
  132.    char packing_method;       /* 0 = no packing, 1 = normal LZW */
  133.    long next;                 /* pos'n of next directory entry */
  134.    long offset;               /* position of this file */
  135.    unsigned int date;         /* DOS format date */
  136.    unsigned int time;         /* DOS format time */
  137.    unsigned int file_crc;     /* CRC of this file */
  138.    long org_size;
  139.    long size_now;
  140.    char major_ver;
  141.    char minor_ver;            /* minimum version needed to extract */
  142.    char deleted;              /* will be 1 if deleted, 0 if not */
  143.    char struc;                /* file structure if any */
  144.    long comment;              /* points to comment;  zero if none */
  145.    unsigned int cmt_size; /* length of comment, 0 if none */
  146.    char fname[FNAMESIZE]; /* filename */
  147.  
  148.    int var_dir_len;           /* length of variable part of dir entry */
  149.    char tz;                   /* timezone where file was archived */
  150.    unsigned int dir_crc;      /* CRC of directory entry */
  151.  
  152.    /* fields for variable part of directory entry follow */
  153.    char namlen;               /* length of long filename */
  154.    char dirlen;               /* length of directory name */
  155.    char lfname[LFNAMESIZE];   /* long filename */
  156.    char dirname[PATHSIZE];    /* directory name */
  157.    int system_id;             /* Filesystem ID */
  158. };
  159.  
  160. /* Values for direntry.system_id */
  161. #define SYSID_NIX       0     /* UNIX and similar filesystems */
  162. #define SYSID_MS        1     /* MS-DOS filesystem */
  163. #define SYSID_PORTABLE  2     /* Portable syntax */
  164.  
  165. /*-End of Zoo stuff---------------------------------------------------------*/
  166.  
  167. /*--------------------------------------------------------------------------*/
  168. /*-Start of DWC stuff-------------------------------------------------------*/
  169. /*--------------------------------------------------------------------------*/
  170.  
  171. #pragma pack(1)        /* req'd by MSC to keep struct byte aligned    */ 
  172.  
  173. /* ENTRY - information that is stored for each file in the DWC archive.      */
  174.  
  175. struct dwc_entry {
  176.    char     name[13];      /* ... File name, Note: path is not saved here    */
  177.    long     size;          /* ... Size of file before compression in bytes   */
  178.    long     time;          /* ... Time stamp on file before added to archive */
  179.    long     new_size;      /* ... Size of compressed file                    */
  180.    long     pos;           /* ... Position of file in archive file           */
  181.    char     method;        /* ... Method of compression used on file         */
  182.    char     sz_c;          /* ... Size of comment added to file              */
  183.    char     sz_d;          /* ... Size of directory name recorded on add     */
  184.    unsigned crc;           /* ... CRC value computed for this file           */
  185. };
  186.  
  187. /* ARCHIVE - information that is stored at the end of every achive.          */
  188.  
  189. struct dwc_arc {
  190.    unsigned size;          /* ... Size of archive structure, future expansion*/
  191.    char     ent_sz;        /* ... Size of directory entry, future expansion  */
  192.    char     header[13];    /* ... Name of Header file to print on listings   */
  193.    long     time;          /* ... Time stamp of last modification to archive */
  194.    long     entries;       /* ... Number of entries in archive               */
  195.    char     id[3];         /* ... the string "DWC" to identify archive       */
  196. };
  197. #pragma pack()
  198. /*-End of DWC stuff---------------------------------------------------------*/
  199.  
  200. /*--------------------------------------------------------------------------*/
  201. /* PKZIP (Phil Katz)                                                        */
  202. /*--------------------------------------------------------------------------*/
  203.  
  204. #pragma pack(1)        /* req'd by MSC to keep struct byte aligned    */ 
  205.  
  206. struct ID_Hdr {
  207.     word    PK_ID;        /* Always = PK = 0x4B50  */
  208.     word    Head_Type;        /* Identifiles which type of header this is */
  209. };
  210.  
  211. #define     LOCAL_HEADER    0x0403        /* PK local header 0x04034B50 */
  212. #define     CENTRAL_DIR     0x0201        /* "Central header"towards end of file */
  213. #define     CENTRAL_REC     0x0605        /* Last header in file */
  214.  
  215. struct Local_Hdr {
  216.     word    extract_ver;    /* check program ver needed to unpack */
  217.     word    GP_flags;        /* General purpose flags, see below */
  218.     word    compression;    /* Compression method */
  219.     word    mod_time;        /* Modification time */
  220.     word    mod_date;        /* Modification date */
  221.     long    crc;            /* File's CRC */
  222.     long    size_now;       /* compressed size */
  223.     long    real_size;        /* un-compressed file size */
  224.     word    name_length;        /* FileName length */
  225.     word    Xfield_length;        /* Extra field length */
  226. };
  227.  
  228. /* Filename follows, no null terminator! */
  229. /* Extra field, no null terminator. */
  230.  
  231. /*--------------------------------------------------------------------------*/
  232. /* Flags used with extract_ver                                              */
  233. /*--------------------------------------------------------------------------*/
  234. #define     IBM     0x0001        /* MS-DOS version of PKZIP */
  235. #define     AMIGA   0x0002        /* Amiga version of PKZIP */
  236. #define     VMS     0x0004        /* VMS version of PKZIP */
  237. #define     UNIX    0x0008        /* UNIX version of PKZIP (C) Bell Labs */
  238.  
  239. /*--------------------------------------------------------------------------*/
  240. /* Flags used with general purpose flags                                    */
  241. /*--------------------------------------------------------------------------*/
  242. #define     ENCRYPT 0x0001        /* File is encrypted */
  243.  
  244. struct  Central_File {
  245.     word    extract_ver;    /* check program ver needed to unpack */
  246.     word    GP_flags;        /* General purpose flags, see below */
  247.     word    compression;    /* Compression method */
  248.     word    mod_time;        /* Modification time */
  249.     word    mod_date;        /* Modification date */
  250.     long    crc;            /* File's CRC */
  251.     long    size_now;       /* compressed size */
  252.     long    real_size;        /* un-compressed file size */
  253.     word    name_length;        /* FileName length */
  254.     word    Xfield_length;        /* Extra field length */
  255.     word    comment_length;        /* File comment length */
  256.     word    disk_start;        /* "Number of disk on which this file begins" */
  257.     word    int_attrib;        /* See internal flags below */
  258.     long    ext_attrib;        /* file's original attributes */
  259.     long    rel_offset;        /* Offset from start of disk/ZIP to local header */
  260. };
  261. /* File Name    */
  262. /* Extra Field  */
  263. /* Comment      */
  264.  
  265. /*--------------------------------------------------------------------------*/
  266. /* Internal Flags                                                           */
  267. /*--------------------------------------------------------------------------*/
  268.  
  269. #define     IS_TEXT     0x0001        /* This file is probably text */
  270.  
  271. struct  Central_Directory {
  272.     word    disk_number;        /* Number of this disk */
  273.     word    center_disk;        /* Number of disk where Central Dir starts */
  274.     word    total_disk;            /* Total # of entries on this disk */
  275.     word    total_entry;        /* Total # of files in this Zipfile */
  276.     long    central_size;        /* Size of the entire central directory */
  277.     long    start_offset;        /*  */
  278.     word    zip_cmnt_len;        /* Length of comment for entire file */
  279. };
  280.  
  281. /* Zipfile comment */
  282. #pragma pack()
  283.  
  284. /*--------------------------------------------------------------------------*/
  285. /* LHARC                                                                    */
  286. /*--------------------------------------------------------------------------*/
  287. #pragma pack(1)
  288.  
  289. struct Lharc_Hdr {
  290.     byte    size_header;        /* No. bytes in header - 2 (0 = EOF) */
  291.     byte    chksum_header;        /* Checksum of remaining bytes */
  292.     char    type[5];        /* Compression type, no NULL terminator! */
  293.     long    size_now;        /* Size of compressed file */
  294.     long    orig_size;        /* Original size of file */
  295.     word    time;        /* file time */
  296.     word    date;        /* file date */
  297.     word    attrib;        /* file attribute */
  298.     byte    name_len;        /* length of file name */
  299. };
  300. /*  char    file_name;   Not terminated!                                                   */
  301. /*  char    crc_char[2]; */
  302. #pragma pack()
  303.  
  304.  
  305. #define FOSSIL_INT   0x14
  306.  
  307. /*---------------------------------------------------------------------*/
  308. /* comm fossil line and modem status in AX.  Status bits returned are: */
  309. /*---------------------------------------------------------------------*/
  310.                      /* In AH: */
  311. #define RDA  0x0100  /* input data is available in buffer */
  312. #define OVRN 0x0200  /* the input buffer has been overrun */
  313. #define THRE 0x2000  /* room is available in output buffer */
  314. #define TSRE 0x4000  /* output buffer is empty */
  315.                      /* In AL: */
  316. #define FRDY 0x0008  /* fossil ready - Always 1 */
  317. #define DCD  0x0080  /* carrier detect */
  318.  
  319.  
  320.  
  321.